package com.hymall.controller.wx;

import com.hymall.bean.common.BaseRespVo;
import com.hymall.bean.vo.WxSearchKeywordVO;
import com.hymall.service.wx.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 长平居士 - rolfcui@outlook.com
 * @description 搜索模块
 * @date 2022/7/19 17:26
 */
@RestController
@RequestMapping("wx/search")
public class WxSearchController {

    @Autowired
    SearchService searchService;

    @GetMapping("index")
    public BaseRespVo index() {
        WxSearchKeywordVO vo = searchService.index();
        return BaseRespVo.ok(vo);
    }

    @GetMapping("helper")
    public BaseRespVo helper(String keyword) {
        List<String> list = searchService.getKeyword(keyword);
        return BaseRespVo.ok(list);
    }

    @PostMapping("clearhistory")
    public BaseRespVo clearHistory() {
        searchService.clearHistory();
        return BaseRespVo.ok();
    }
}
